/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package comunicacao;

import entities.Teatro;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 *
 * @author Leonardo Lino
 */
public class RmiClient {

    ReceiveMessageInterface rmiServer;
    Registry registry;
    String serverAddress = "10.101.225.146";
    String serverPort = "3232";
    String text;

    public String start() {

        try {
            registry = LocateRegistry.getRegistry(
                    serverAddress,
                    (new Integer(serverPort)).intValue());
            System.out.println("meu registo:" + registry.list());

            // look up the remote object
            rmiServer =(ReceiveMessageInterface) (registry.lookup("dbServer"));
            
            // call the remote method
            Teatro teatro = rmiServer.getTheater(1);
            return teatro.getNome();

        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (NotBoundException e) {
            e.printStackTrace();
        }
        
        return "nada";
    }
}
